part of '../repository.dart';

const _kPurchasedSubscriptionInfoCancellationUnspecifiedSurveyReasonValue = 'unspecified';
const _kPurchasedSubscriptionInfoCancellationOtherSurveyReasonValue = 'other';
const _kPurchasedSubscriptionInfoCancellationInsufficientUseSurveyReasonValue = 'insufficient_use';
const _kPurchasedSubscriptionInfoCancellationTechnicalIssuesSurveyReasonValue = 'technical_issues';
const _kPurchasedSubscriptionInfoCancellationCostSurveyReasonValue = 'cost';
const _kPurchasedSubscriptionInfoCancellationNotBestAppSurveyReasonValue = 'not_best_app';

class _PurchasedSubscriptionInfoCancellationSurveyReasonDto extends Equatable {
  const _PurchasedSubscriptionInfoCancellationSurveyReasonDto._internal({
    required this.reasonString,
  });

  final String reasonString;

  @override
  List<Object?> get props {
    return [
      reasonString,
    ];
  }

  factory _PurchasedSubscriptionInfoCancellationSurveyReasonDto.fromString(String reasonString) {
    return _PurchasedSubscriptionInfoCancellationSurveyReasonDto._internal(
      reasonString: reasonString,
    );
  }

  factory _PurchasedSubscriptionInfoCancellationSurveyReasonDto.fromEntity(
      GooglePlayPurchasedSubscriptionInfoCancellationSurveyReason reason) {
    late final String reasonString;

    if (reason == GooglePlayPurchasedSubscriptionInfoCancellationSurveyReason.unspecified) {
      reasonString = _kPurchasedSubscriptionInfoCancellationUnspecifiedSurveyReasonValue;
    } else if (reason == GooglePlayPurchasedSubscriptionInfoCancellationSurveyReason.other) {
      reasonString = _kPurchasedSubscriptionInfoCancellationOtherSurveyReasonValue;
    } else if (reason == GooglePlayPurchasedSubscriptionInfoCancellationSurveyReason.insufficientUse) {
      reasonString = _kPurchasedSubscriptionInfoCancellationInsufficientUseSurveyReasonValue;
    } else if (reason == GooglePlayPurchasedSubscriptionInfoCancellationSurveyReason.technicalIssues) {
      reasonString = _kPurchasedSubscriptionInfoCancellationTechnicalIssuesSurveyReasonValue;
    } else if (reason == GooglePlayPurchasedSubscriptionInfoCancellationSurveyReason.cost) {
      reasonString = _kPurchasedSubscriptionInfoCancellationCostSurveyReasonValue;
    } else if (reason == GooglePlayPurchasedSubscriptionInfoCancellationSurveyReason.notBestApp) {
      reasonString = _kPurchasedSubscriptionInfoCancellationNotBestAppSurveyReasonValue;
    }

    return _PurchasedSubscriptionInfoCancellationSurveyReasonDto._internal(
      reasonString: reasonString,
    );
  }

  @override
  String toString() {
    return reasonString;
  }

  GooglePlayPurchasedSubscriptionInfoCancellationSurveyReason toEntity() {
    if (reasonString == _kPurchasedSubscriptionInfoCancellationUnspecifiedSurveyReasonValue) {
      return GooglePlayPurchasedSubscriptionInfoCancellationSurveyReason.unspecified;
    } else if (reasonString == _kPurchasedSubscriptionInfoCancellationOtherSurveyReasonValue) {
      return GooglePlayPurchasedSubscriptionInfoCancellationSurveyReason.other;
    } else if (reasonString ==
        _kPurchasedSubscriptionInfoCancellationInsufficientUseSurveyReasonValue) {
      return GooglePlayPurchasedSubscriptionInfoCancellationSurveyReason.insufficientUse;
    } else if (reasonString ==
        _kPurchasedSubscriptionInfoCancellationTechnicalIssuesSurveyReasonValue) {
      return GooglePlayPurchasedSubscriptionInfoCancellationSurveyReason.technicalIssues;
    } else if (reasonString == _kPurchasedSubscriptionInfoCancellationCostSurveyReasonValue) {
      return GooglePlayPurchasedSubscriptionInfoCancellationSurveyReason.cost;
    } else if (reasonString == _kPurchasedSubscriptionInfoCancellationNotBestAppSurveyReasonValue) {
      return GooglePlayPurchasedSubscriptionInfoCancellationSurveyReason.notBestApp;
    }

    throw UnimplementedError();
  }
}
